[XEND] Fix xm vcpu-set when decrementing VCPU count
authorAlastair Tse <atse@xensource.com>
Fri, 8 Dec 2006 11:08:26 +0000 (11:08 +0000)
committerAlastair Tse <atse@xensource.com>
Fri, 8 Dec 2006 11:08:26 +0000 (11:08 +0000)
Signed-off-by: Alastair Tse <atse@xensource.com>
tools/python/xen/xend/XendConfig.py
tools/python/xen/xend/XendDomainInfo.py
tools/python/xen/xm/main.py

index 74ff06284d79c140202f07cd35919710dad87568..9896254f32cbdde5ab94ae14e3aaee3c1b395159 100644 (file)
@@ -632,6 +632,9 @@ class XendConfig(dict):
         self['memory_dynamic_max'] = self['memory_static_max']
         self['memory_dynamic_min'] = self['memory_static_min']
 
+        # make sure max_vcpu_id is set correctly
+        self['max_vcpu_id'] = self['vcpus_number'] - 1
+
         # set device references in the configuration
         self['devices'] = cfg.get('devices', {})
         
@@ -714,7 +717,7 @@ class XendConfig(dict):
         _set_cfg_if_exists('on_xend_stop')
         _set_cfg_if_exists('on_xend_start')
         _set_cfg_if_exists('vcpu_avail')
-        _set_cfg_if_exists('max_vcpu_id') # TODO, deprecated?
+        _set_cfg_if_exists('max_vcpu_id') # needed for vcpuDomDetails
         
         # Parse and store runtime configuration 
         _set_cfg_if_exists('start_time')
index 29ce17083c99c8b04cc23038e33e6f081bd011d4..c0a66aaf67959bae8029ddc8efcdd959b893a2c1 100644 (file)
@@ -876,10 +876,18 @@ class XendDomainInfo:
 
     def setVCpuCount(self, vcpus):
         self.info['vcpu_avail'] = (1 << vcpus) - 1
-        self.info['vcpus_number'] = vcpus
         self.storeVm('vcpu_avail', self.info['vcpu_avail'])
-        self.storeVm('vcpus', self.info['vcpus_number'])
-        self._writeDom(self._vcpuDomDetails())
+        # update dom differently depending on whether we are adjusting
+        # vcpu number up or down, otherwise _vcpuDomDetails does not
+        # disable the vcpus
+        if self.info['vcpus_number'] > vcpus:
+            # decreasing
+            self._writeDom(self._vcpuDomDetails())
+            self.info['vcpus_number'] = vcpus
+        else:
+            # same or increasing
+            self.info['vcpus_number'] = vcpus
+            self._writeDom(self._vcpuDomDetails())
 
     def getLabel(self):
         return security.get_security_info(self.info, 'label')
index 6850061908d1e2e5a4948f08130f864aa0dbc898..dff82536399556393fd9b7a2fbe1647431cada7a 100644 (file)
@@ -643,7 +643,7 @@ def parse_doms_info(info):
         'domid'    : get_info('domid',        str,   ''),
         'name'     : get_info('name',         str,   '??'),
         'mem'      : get_info('memory_dynamic_min', int,   0),
-        'vcpus'    : get_info('vcpus',        int,   0),
+        'vcpus'    : get_info('online_vcpus',        int,   0),
         'state'    : get_info('state',        str,    ''),
         'cpu_time' : get_info('cpu_time',     float, 0),
         'up_time'  : up_time,